------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\figure2.log
  log type:  text
 opened on:  30 Mar 2017, 13:55:41

. 
. set more off

. #delimit ;
delimiter now ;
. *     ***************************************************************** *;
. *     ***************************************************************** *;
. *       File-Name:      africancabinets_figure2.do                      *;
. *       Date:           September 17, 2016                              *;
. *       Author:         Molly Ariotti and Sona Golder                   *;
. *       Purpose:        Produce Figure 2 for CPS African portfolio      *;
. *                       allocation paper.                               *;
. *           Input File:     Africa.dta                                      *;
. *       Output File:    figure2.log, africa.eps                         *;
. *       Data Output:    none                                            *;
.              *       Previous file:  none                                            *;
. *       Machine:        laptop                                                          *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. use "C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\Africa.dta";

. sum;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
 countryname |          0
 countrycode |         84    5.559524    2.552349          1          9
 cabinetcode |         84    13.89286    8.034591          1         28
     cowcode |         84    517.8452    69.14373        403        590
        year |         84    2002.357    6.825965       1990       2014
-------------+---------------------------------------------------------
presidential |         84    .3690476    .4854451          0          1
   formateur |         84    .3095238    .4650739          0          1
  portfolios |         84     7.02381    6.860005          1         26
governmen~os |         84    21.08333    6.637259          9         35
 party_seats |         84    39.91667    56.69368          1        279
-------------+---------------------------------------------------------
governmen~ts |         84    115.0952    86.61028         39        377
      region |         84           1           0          1          1
portfolios~e |         84    .3333333     .282168   .0344828   .9545454
   seatshare |         84    .3333333    .2628826   .0034843    .990099
       party |         84    25.91667    13.80083          1         48
-------------+---------------------------------------------------------
        code |         84    105573.4    2560.162     101001     109028

. *     ****************************************************************  *;
. *       Create perfect proportionality data                             *;
. *     ****************************************************************  *;
. set obs 100;
number of observations (_N) was 84, now 100

. gen seats=.;
(100 missing values generated)

. replace seats=_n/100 if _n<101;
(100 real changes made)

. gen ports=.;
(100 missing values generated)

. replace ports=_n/100 if _n<101;
(100 real changes made)

. *     ****************************************************************  *;
. *       Produce Figure 2                                                *;
. *     ****************************************************************  *;
. scatter portfolioshare seatshare if formateur==1, msymbol(O) mcolor(red) msize(medsmall)
>         || scatter portfolioshare seatshare if formateur==0, msymbol(Oh) mcolor(eltblue)  msize(medsmall) 
>         || line ports seats if seatshare>0, lcolor(black) clpattern(solid) 
>         legend(col(1) size(2.5) region(lstyle(color(white))) order(1 2) position(5) ring(0) label(1 "{stSerif:Fo
> rmateur Party}") label(2 "{stSerif:Not a Formateur Party}"))
>         xtitle("{stSerif:Share of Government's Legislative Seats}", size(3) height(7)) 
>         ytitle("{stSerif:Share of Cabinet Portfolios}" , size(3) height(7))
>         xlabel(0 0.2 0.4 0.6 0.8 1.0, nogrid labsize(2.5))
>         ylabel(0 0.2 0.4 0.6 0.8 1.0, nogrid labsize(2.5)) 
>         scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white));

.         graph export "C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\africa.eps", replace;
(file C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\africa.eps written in EPS format)

. *     ****************************************************************  *;
. *       What is the average distance from the 45 degree line?           *;
. *     ****************************************************************  *;
. gen error = abs(portfolioshare-seatshare);
(16 missing values generated)

. egen sum_error = sum(error);

. gen average_error=sum_error/76;

. sum average_error;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
average_er~r |        100    .0593748           0   .0593748   .0593748

. gen error2 = abs(portfolioshare-seatshare) if formateur==1;
(74 missing values generated)

. egen sum_error2 = sum(error2);

. gen average_error2=sum_error2/26;

. sum average_error2;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
average_er~2 |        100    .0640144           0   .0640144   .0640144

. log close;
      name:  <unnamed>
       log:  C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\figure2.log
  log type:  text
 closed on:  30 Mar 2017, 13:55:42
------------------------------------------------------------------------------------------------------------------
